package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	Mysql
	AliPay
}

type Mysql struct {
	User     string
	Password string
	Host     string
	Port     int
	Database string
}
type AliPay struct {
	PrivateKey string
	AppId      string
	NotifyURL  string
	ReturnURL  string
}

var AppConf AppConfig

func GetViper() {
	viper.SetConfigFile("./appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		panic("配置文件读取失败")
	}
	err = viper.Unmarshal(&AppConf)
	if err != nil {
		panic("配置文件解析失败")
	}
	fmt.Println(AppConf)
}
